<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 2017/7/12
 * Time: 16:35
 * Project name: PHPTEST
 * File name: 4.php
 * @copyright Copyright (c) 2016 ZRX Software LLC
 * @license https://github.com/zhangrxiang
 * @since 1.0.0
 */

$file_name = 'test.txt';
$file=null;
if(!file_exists($file_name)){
	touch($file_name);
}else{
	$file = fopen($file_name,'a+') or die("fuck");
}
if ($file){
	if(file_get_contents($file_name) == ''){
		$content = stream_get_contents(fopen(__FILE__,'r'));
		fwrite($file,$content,strlen($content));
	}else{
		while (!feof($file)){
			$fread = fread( $file ,1);
			echo $fread;
		}
		fseek($file,0);
		echo fread( $file ,1024);
	}
	fputs($file,PHP_EOL.'fputs'.date("Y-m-d H:i:s",time()));
	fputcsv($file,[1,2,3,4,5,6],'-','a',"\\");
	$fstat = fstat( $file );
	var_dump($fstat);
	fclose($file);
}